package com.everyline.baselibrary.utils

import android.os.Handler
import android.os.Looper

/**
 *creatd by 天天挂线
 *email:746608431@qq.com
 *on 2020/7/10
 *描述:TODO
 */
class HandlerUtils {
    companion object {
        private val HANDLER = Handler(Looper.getMainLooper())

        fun runOnUiThread(runnable: Runnable?) {
            if (runnable != null) {
                HANDLER.post(runnable)
            }
        }

        fun runOnUiThreadDelay(
            runnable: () -> Unit,
            delayMillis: Long
        ) {
            HANDLER.postDelayed(runnable, delayMillis)
        }

        fun removeRunable(runnable: Runnable?) {
            if (runnable != null) {
                HANDLER.removeCallbacks(runnable)
            }
        }
    }

}